<?php
/**
 * @file
 * @package mileage
 * @version $Id$
**/

if (!defined('XOOPS_ROOT_PATH')) {
	exit;
}

require_once MILEAGE_TRUST_PATH . '/class/AbstractDeleteAction.class.php';

/**
 * Mileage_Admin_MileDeleteAction
**/
class Mileage_Admin_MileDeleteAction extends Mileage_AbstractDeleteAction
{
	/**
	 * _getId
	 * 
	 * @param   void
	 * 
	 * @return  int
	**/
	protected function _getId()
	{
		return $this->mRoot->mContext->mRequest->getRequest('mile_id');
	}

	/**
	 * &_getHandler
	 * 
	 * @param   void
	 * 
	 * @return  Mileage_MileHandler
	**/
	protected function &_getHandler()
	{
		$handler =& $this->mAsset->getObject('handler', 'mile');
		return $handler;
	}

	/**
	 * _setupActionForm
	 * 
	 * @param   void
	 * 
	 * @return  void
	**/
	protected function _setupActionForm()
	{
		// $this->mActionForm =& new Mileage_Admin_MileDeleteForm();
		$this->mActionForm =& $this->mAsset->getObject('form', 'mile', true, 'delete');
		$this->mActionForm->prepare();
	}

	/**
	 * executeViewInput
	 * 
	 * @param   XCube_RenderTarget  &$render
	 * 
	 * @return  void
	**/
	public function executeViewInput(&$render)
	{
		$render->setTemplateName('mile_delete.html');
		$render->setAttribute('actionForm', $this->mActionForm);
		$render->setAttribute('object', $this->mObject);
	}

	/**
	 * executeViewSuccess
	 * 
	 * @param   XCube_RenderTarget  &$render
	 * 
	 * @return  void
	**/
	public function executeViewSuccess(&$render)
	{
		$this->mRoot->mController->executeForward('./index.php?action=MileList');
	}

	/**
	 * executeViewError
	 * 
	 * @param   XCube_RenderTarget  &$render
	 * 
	 * @return  void
	**/
	public function executeViewError(&$render)
	{
		$this->mRoot->mController->executeRedirect('./index.php?action=EditList', 1, _MD_MILEAGE_ERROR_DBUPDATE_FAILED);
	}

	/**
	 * executeViewCancel
	 * 
	 * @param   XCube_RenderTarget  &$render
	 * 
	 * @return  void
	**/
	public function executeViewCancel(&$render)
	{
		$this->mRoot->mController->executeForward('./index.php?action=MileList');
	}

}
